﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace SaaS
{
    public partial class Keywords : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button_Search_Click(object sender, EventArgs e)
        {
            List<string> output;
            SaaS.searchKeywords sKeywords = new SaaS.searchKeywords();
            
            // return a string list with score larger than threshold, 
            // sorted by the score, the first one has the largest score
            // default threshold is 0.75
            output= sKeywords.findKeywords(TB_Keywords.Text.Trim(),0.3);
            if (output.Count == 0)
                Label_Keywords.Text = "Sorry, No Match found!";
            else
            {
                string str="";
                for (int i = 0; i < output.Count; i++)
                    str = str + "  "+output[i];
                Label_Keywords.Text = "keywords found:  "+str;
            }

            //find services
            SaaS.searchOntology sOntology = new SaaS.searchOntology();
            if (output.Count > 0)
            {
                HashSet<string> serviceIdList = sOntology.findService(output);
                string display = "";
                foreach (string str in serviceIdList)
                {
                    display = display + "  " + str;
                }
                Label_serviceID.Text = "service id found:  " + display;
            }
        }
    }
}